package com.cy.pj.goods.dao;

import com.cy.pj.goods.pojo.Goods;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 商品模块持久层对象
 */
@Mapper
public interface GoodsDao {

    @Update("update tb_goods set name=#{name},remark=#{remark} where id=#{id}")
    int updateGoods(Goods entity);

    @Select("select * from tb_goods where id=#{id}")
    Goods findById(Integer id);

    @Insert("insert into tb_goods(name,remark,createdTime) values(#{name},#{remark},now()) ")
    int insertGoods(Goods entity);

    @Delete("delete from tb_goods where id=#{id}")
    int deleteById(Integer id);
    /**
     * 查询所有商品信息
     * @return 所有商品
     * mybatis框架中定义sql映射两种方式
     * 1，注解方式
     * 2，xml方式
     */
    @Select("select * from tb_goods")
    List<Goods> findGoods();
}
